package model.entity;

import java.util.List;

import model.entity.brain.Brain;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.item.EquippedInventory;
import model.item.Inventory;
import model.item.TakeableItem;
import model.map.Direction;
import model.map.Location;
import model.map.MovementType;
import utilities.*;

/**
 * 
 * This is the merchant
 * NPC in the game that the avatar can communicate with
 *
 */

public class MerchantNPC extends NPC implements Talkable, Archiveable {

	protected List<String> dialog;

	public MerchantNPC(String name, Direction direction, Location location, StatSet stats, 
			List<MovementType> movementTypes, Inventory inventory, 
			EquippedInventory equipment, Occupation occupation, Boolean sleeping, Brain brain, List<String> dialog){

		super(name,  direction, location, stats, 
				movementTypes, inventory, 
				equipment, occupation, sleeping, brain);

		this.dialog = dialog;

	}

	public MerchantNPC() {
		// TODO Auto-generated constructor stub
	}

	public List<String> getDialog(){
		return dialog;
	}

	public boolean buyItem(TakeableItem item){
		int itemCost = item.getPrice();

		if(stats.getStatVal(StatType.MONEY) > itemCost){
			inventory.addItem(item);
			stats.addConstantModifier(StatType.MONEY, -itemCost);
			return true;
		}
		return false;
			
	}
	public void sellItem(TakeableItem item){
		int itemCost = item.getPrice();
		stats.addConstantModifier(StatType.MONEY, itemCost);
		inventory.removeItem(item);
	
	}
	
	public Archive save() {
		Archive archive = super.save();
		
//		archive.putAttributeList("dialog", this.dialog);
		
		return archive;
	}
	
	public void load(Archive archive) {
		super.load(archive);
		
//		this.dialog = archive.getAttributeList("dialog");
	}

}
